import HttpKit from '@/utils/http-kit'

export default {
  /**
   * @description 获取任务列表
   * @returns {Promise<T | never>}
   */
  getTaskList () {
    return HttpKit.get('/workorders', {pageNumber: '0', pageSize: '500'}).then(
      res => res.data
    )
  },
  /**
   * @description 通过工人编号获取列表列表
   * @param id
   * @returns {Promise<T | never>}
   */
  getTaskListByWorkerId (id) {
    return HttpKit.get('/workorder/workerid/' + id, {pageNumber: '0', pageSize: '10000'}).then(
      res => res.data
    )
  },
  /**
   * @description 通过业务员编号获取任务列表
   * @param id
   * @returns {Promise<T | never>}
   */
  getTaskListBySellId (id) {
    return HttpKit.get('/workorder/sellId/' + id, {pageNumber: '0', pageSize: '10000'}).then(
      res => res.data
    )
  },
  /**
   * @description 工人点击完成表示完成任务
   * @param task
   * @returns {Promise<T | never>}
   */
  accomplish (task) {
    return HttpKit.put('/workorder/accomplish', {
      'address': task.address,
      'id': task.id,
      'sellId': task.sellId,
      'orderId': task.orderId,
      'spotId': task.spotId,
      'status': task.status,
      'workType': task.workType,
      'workerId': task.workerId
    }).then(
      res => res.data
    )
  }
}
